package com.kehao.leetcode.middle.dp;

import org.junit.Test;

public class JumpGame {
    public boolean canJump(int[] nums) {
        boolean[] dp = new boolean[nums.length];
        dp[0]=true;
        for (int i = 1; i < nums.length; i++) {
            for (int j = 0; j < i; j++) {
                if(dp[j]==true&&nums[j]+j>=i){
                    dp[i]=true;
                    break;
                }
            }
        }
        return dp[nums.length-1];
    }

    @Test
    public void test01(){
        int[] nums = {2,3,1,1,4};
        System.out.println(canJump(nums));
    }

    @Test
    public void test02(){
        int[] nums = {3,2,1,0,4};
        System.out.println(canJump(nums));
    }
}
